package com.nuanshui.heatedloan.baseservice.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.nuanshui.framework.lang.SysStringUtils;
import com.nuanshui.framework.res.ResourceFacade;
import com.nuanshui.framework.springContext.SpringContextUtil;
import com.nuanshui.framework.utils.FlagOperationFactory;
import com.nuanshui.heatedloan.constant.UserAuthType;

import java.math.BigInteger;

public class UserInfo extends User {

	private static final long serialVersionUID = 1L;

	@SuppressWarnings("unused")
	private String avatarUrl;// 头像地址

	private boolean self;
	private boolean interested;
	private Boolean beInterested;
	private Integer limitPostCount;
	private Boolean isBindWeibo;
	@SuppressWarnings("unused")
	private Boolean isBindPhone;// 是否绑定手机号
	private Boolean hasSearchCertificate;
	private Long postCount;// 帖子总数
	@JsonIgnore
	@JSONField(serialize = false)
	private BigInteger interesteds;
	@JsonIgnore
	@JSONField(serialize = false)
	private BigInteger fans;
	@JsonIgnore
	@JSONField(serialize = false)
	private BigInteger likes;
	@JsonIgnore
	@JSONField(serialize = false)
	private BigInteger posts;
	@JsonIgnore
	@JSONField(serialize = false)
	private BigInteger favorites;
	
	private Long auth;// 用户的权限
	@SuppressWarnings("unused")
	private Boolean vip;//是否是会员
	
	public boolean isVip() {
        return FlagOperationFactory.getPosOp().containFlag(auth, UserAuthType.MEMBERSHIP);
	}
	public void setVip() {
		this.vip = FlagOperationFactory.getPosOp().containFlag(auth, UserAuthType.MEMBERSHIP);
	}
	public Long getPostCount() {
		return postCount;
	}

	public Long getFansCount() {
		return fansCount;
	}

	public Long getFavoritesCount() {
		return favoritesCount;
	}

	private Long imgCount;
	private String intro;

	private String qrcode;// 二维码

	private String selfhoodImg;
	private Long praiseCount;// 点赞次数
	private Long fansCount;// 粉丝数
	private Long favoritesCount; // 订阅数
	private Long interestedCount;// 关注数
	private Long likeCount; //收藏数

	private Double score;// 积分
	private int level;// 等级
	private String levelName;// 等级名称
	@SuppressWarnings("unused")
	private Boolean verified;
	private Integer verifiedType;
	private Integer praised;// 是否可以点赞
	private Integer loginAccountType = 4;// 登录的用户类型
	private String des;// 描述
	private String verifiedInfo;// 认证信息
	private String verifiedInfoImg;// 认证信息图片
	private String introImg;// 用户信息图片
	private boolean isSign;// 是否认证
	private String channel;// 来自那个市场

	public String getChannel() {
		return channel;
	}

	public void setChannel(String channel) {
		this.channel = channel;
	}

	public boolean getIsSign() {
		return isSign;
	}

	public void setIsSign(boolean isSign) {
		this.isSign = isSign;
	}

	public String getDes() {
		return des;
	}

	public void setDes(String des) {
		this.des = des;
	}

	public String getVerifiedInfo() {
		return verifiedInfo;
	}

	public void setVerifiedInfo(String verifiedInfo) {
		this.verifiedInfo = verifiedInfo;
	}

	public String getVerifiedInfoImg() {
		return verifiedInfoImg;
	}

	public void setVerifiedInfoImg(String verifiedInfoImg) {
		this.verifiedInfoImg = verifiedInfoImg;
	}

	public String getIntroImg() {
		return introImg;
	}

	public void setIntroImg(String introImg) {
		this.introImg = introImg;
	}

	public Boolean getIsBindPhone() {
		return SysStringUtils.isNotEmpty(this.getPhone());
	}

	public void setIsBindPhone(Boolean isBindPhone) {
		this.isBindPhone = isBindPhone;
	}

	public Integer getLoginAccountType() {
		return loginAccountType;
	}

	public void setLoginAccountType(Integer loginAccountType) {
		this.loginAccountType = loginAccountType;
	}


	public Long getAuth() {
		return auth;
	}

	public void setAuth(Long auth) {
		this.auth = auth;
	}

	public Integer getPraised() {
		return praised;
	}

	public void setPraised(Integer praised) {
		this.praised = praised;
	}

	public void setFansCount(Long fansCount) {
		this.fansCount = fansCount;
	}

	public Long getPraiseCount() {
		return praiseCount;
	}

	public void setPraiseCount(Long praiseCount) {
		this.praiseCount = praiseCount;
	}

	public String getLevelName() {
		return levelName;
	}

	public void setLevelName(String levelName) {
		this.levelName = levelName;
	}

	public boolean getVerified() {
		if (verifiedType == null)
			return false;
		return verifiedType > 0;
	}

	public void setVerified(Boolean verified) {
		this.verified = verified;
	}

	public String getSelfhoodImg() {
		return selfhoodImg;
	}

	public void setSelfhoodImg(String selfhoodImg) {
		this.selfhoodImg = selfhoodImg;
	}

	public String getQrcode() {
		return qrcode;
	}

	public void setQrcode(String qrcode) {
		this.qrcode = qrcode;
	}

	public String getIntro() {
		return intro;
	}

	public void setIntro(String intro) {
		this.intro = intro;
	}

	public Double getScore() {
		if (score == null || score < 0)
			return 0d;
		return score;
	}

	public void setScore(Double score) {
		this.score = score;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public Long getImgCount() {
		return imgCount;
	}

	public void setImgCount(Long imgCount) {
		this.imgCount = imgCount;
	}

	public void setPostCount(Long postCount) {
		this.postCount = postCount;
	}

	public Boolean getHasSearchCertificate() {
		if (hasSearchCertificate == null)
			return false;
		return hasSearchCertificate;
	}

	public void setHasSearchCertificate(Boolean hasSearchCertificate) {
		this.hasSearchCertificate = hasSearchCertificate;
	}

	public Boolean getIsBindWeibo() {
		return isBindWeibo;
	}

	public void setIsBindWeibo(Boolean isBindWeibo) {
		this.isBindWeibo = isBindWeibo;
	}



	public Integer getLimitPostCount() {
		return limitPostCount;
	}

	public void setLimitPostCount(Integer limitPostCount) {
		this.limitPostCount = limitPostCount;
	}

	public String getAvatarUrl() {
		ResourceFacade resourceFacade = SpringContextUtil.getBean(ResourceFacade.class);

		return resourceFacade.resolveUrl(getAvatar());
	}

	public void setAvatarUrl(String avatarUrl) {
		this.avatarUrl = avatarUrl;
	}

	public Boolean getSelf() {
		return self;
	}

	public void setSelf(Boolean self) {
		if (self == null)
			return;
		this.self = self;
	}

	public Boolean getInterested() {
		return interested;
	}

	public void setInterested(Boolean interested) {
		if (interested == null)
			return;
		this.interested = interested;
	}

	public Boolean getBeInterested() {
		return beInterested;
	}

	public void setBeInterested(Boolean beInterested) {
		this.beInterested = beInterested;
	}

	public Integer getVerifiedType() {
		return verifiedType;
	}

	public void setVerifiedType(Integer verifiedType) {
		this.verifiedType = verifiedType;
	}

	@Override
	public boolean isEnabled() {
		return FlagOperationFactory.getPosOp().containFlag(auth, 2);
	}

	public void setFavoritesCount(Long favoritesCount) {
		this.favoritesCount = favoritesCount;
	}

	public Long getInterestedCount() {
		return interestedCount;
	}

	public void setInterestedCount(Long interestedCount) {
		this.interestedCount = interestedCount;
	}

	public Long getLikeCount() {
		return likeCount;
	}

	public void setLikeCount(Long likeCount) {
		this.likeCount = likeCount;
	}

}
